<?php
    require_once ('classes/user.class.php');
    if(session_id()=="") session_start ();
    
    if(isset($_SESSION['user']) && $_SESSION['user']->isAdmin()){
?>

<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="ckeditor/adapters/jquery.js"></script>
<script type="text/javascript" src="js/manage_functions.js"></script>

<h2>Ajout d'une nouvelle news</h2>

<div id="add_news_content" class="content">
    <form id="form_add_news" method="POST" >


        <ul>
                <li>
                        <label class="desc" for="title">Titre</label>
                        <input id="title" name="title" class="field text large" type="text" value=""/>
                </li>
                <br/><br/>
                <li>
                        <textarea id="editor_textarea"></textarea>
                </li>
                <br/><br/>
                <li>
                        <button id="submitButton" type="submit" class="positive button" >
                        <img src="images/ok.png" alt="" />Enregistrer la news</button>
                </li>

        </ul>

    </form>
</div>
<script type="text/javascript" >
       //transforme la textarea en objet JS ckeditor
       $( '#editor_textarea' ).ckeditor();
       
        //desactive le comportement par defaut du formulaire et lance la fonction add_news()
        $('#form_add_news').submit(function(event){
            event.preventDefault();
            add_news();
        })
</script>

<?php
    }
?>
